package com.atguigu.edustatistics.schedule;

import com.atguigu.edustatistics.service.StatisticsDailyService;
import com.atguigu.edustatistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

//定时器
@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService dailyService;

    //在每天的凌晨1点中查询前一天中注册的用户数量
    @Scheduled(cron = "0 15 20 * * ? ")
    public void task1(){
        dailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(),-1)));
    }
}
